<template>
  <div class="search">
    <f-form ref="form" :action="api.material" :form-key="this.formItem.materialId" >
      <f-form-item label="父ID"  name="parenId"    :value="formItem.parenId" />
      <f-form-item label="项目ID"  name="projectId"    :value="formItem.projectId" />
      <f-form-item label="换算单位"  name="conversionUnit"    :value="formItem.conversionUnit" />
      <f-form-item label="综合单价"  name="syntheticalPrice"    :value="formItem.syntheticalPrice" />
      <f-form-item label="综合费"  name="syntheticalAmount"    :value="formItem.syntheticalAmount" />
      <f-form-item label="其他单价"  name="otherPrice"    :value="formItem.otherPrice" />
      <f-form-item label="其他费用"  name="otherAmount"    :value="formItem.otherAmount" />
      <f-form-item label="标前工程量"  name="beforeMarkQuantity"    :value="formItem.beforeMarkQuantity" />
      <f-form-item label="合同清单工程量"  name="contractBillQuantity"    :value="formItem.contractBillQuantity" />
      <f-form-item label="计量单位"  name="measurementUnit"    :value="formItem.measurementUnit" />
      <f-form-item label="损耗"  name="loss" dataType="number"   :value="formItem.loss" />
      <f-form-item label="主材价"  name="mainPrice"    :value="formItem.mainPrice" />
      <f-form-item label="主材费"  name="mainAmount"    :value="formItem.mainAmount" />
      <f-form-item label="安装价"  name="installPrice"    :value="formItem.installPrice" />
      <f-form-item label="安装费"  name="installAmount"    :value="formItem.installAmount" />
      <f-form-item label="有合同综合单价"  name="contractSyntheticalPrice1"    :value="formItem.contractSyntheticalPrice1" />
      <f-form-item label="拟合同综合单价"  name="contractSyntheticalPrice2"    :value="formItem.contractSyntheticalPrice2" />
      <f-form-item label="合同综合单价"  name="contractSyntheticalPrice3"    :value="formItem.contractSyntheticalPrice3" />
      <f-form-item label="创建时间"  name="createTime"    :value="formItem.createTime" />
      <f-form-item label="更新时间"  name="updateTime"    :value="formItem.updateTime" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'materialForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          materialId: '',
          parenId: '',
          projectId: '',
          conversionUnit: '',
          syntheticalPrice: '',
          syntheticalAmount: '',
          otherPrice: '',
          otherAmount: '',
          beforeMarkQuantity: '',
          contractBillQuantity: '',
          measurementUnit: '',
          loss: '',
          mainPrice: '',
          mainAmount: '',
          installPrice: '',
          installAmount: '',
          contractSyntheticalPrice1: '',
          contractSyntheticalPrice2: '',
          contractSyntheticalPrice3: '',
          createTime: '',
          updateTime: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.materialId) {
          let params={
              materialId:data.materialId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
